<%@page import="java.net.URLEncoder"%>
<%@page import="helpers.CkeditorConfigHelper"%>
<%@page import="models.ProductModel"%>
<%@page import="admin.data.ProductData"%>
<%@page import="java.util.Calendar"%>
<%@page import="models.StaffModel"%>
<%@page import="admin.data.StaffData"%>
<%@page import="models.CategoryModel"%>
<%@page import="models.GeoModel"%>
<%@page import="admin.data.GeoData"%>
<%@page import="admin.data.CategoryData"%>
<%@page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory"%>
<%@page import="com.google.appengine.api.blobstore.BlobstoreService"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %> 
<%@page import="models.DealModel"%>
<%@page import="models.SiteConfigModel"%>
<%@page import="java.util.TreeMap"%>
<%@page import="helpers.UrlHelper"%>
<%	
	HttpSession ss = request.getSession();
	BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	CategoryData cateData = new CategoryData();
	GeoData geoData = new GeoData();
	StaffData staffData = new StaffData();
	TreeMap check = new TreeMap();
	String action = "add";
	DealModel deal = new DealModel();	
	if(ss.getAttribute("action")!=null){
		action = (String) ss.getAttribute("action");
		ss.removeAttribute("action");
	}	
	if(ss.getAttribute("check")!=null){
		check = (TreeMap) ss.getAttribute("check");
		ss.removeAttribute("check");
	}		
	if(ss.getAttribute("deal")!=null){
		deal = (DealModel) ss.getAttribute("deal");
		ss.removeAttribute("deal");
	}else{			
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.DATE, cal.get(Calendar.DATE) + 2);
		deal.setEndTime(cal.getTime());
		deal.setExpireTime(cal.getTime());
	}
%>
<jsp:include page="/admin/layouts/header.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<script type="text/javascript" src="/admin/js/static_page.js"></script>
<script type="text/javascript" src="/admin/js/form_deal.js"></script>
<script type="text/javascript" src="/admin/js/plugins/wysiwyg/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="/admin/js/plugins/wysiwyg/wysiwyg.image.js"></script>
<script type="text/javascript" src="/admin/js/plugins/wysiwyg/wysiwyg.link.js"></script>
<script type="text/javascript" src="/admin/js/plugins/wysiwyg/wysiwyg.table.js"></script>
<script language="JavaScript">
<!--
	jQuery(document).ready(function($) { 		
		if(jQuery("input[name='notActiveDeal']").is(':checked')){
			jQuery(".time").hide(100);
		}
		if(jQuery("input[name='mapGoogle']").is(':checked')){
			jQuery("#mapImg").hide(100);
			jQuery("#mapGoo").show(100);
		}else{
			jQuery("#mapGoo").hide(100);
			jQuery("#mapImg").show(100);
		}
		
		if(jQuery("input[name='productCheck']").is(':checked')){
			jQuery("#productInfor").show(100);
		}else{
			jQuery("#productInfor").hide(100);
		}
		
		jQuery("input[name='productCheck']").click(function(){		
			if (jQuery(this).is(':checked')) {  
				jQuery("#productInfor").show(100);
			}else if (jQuery(this).not(":checked")) {   
				jQuery("#productInfor").hide(100);
			}
		}); 
		jQuery("input[name='mapGoogle']").click(function(){		
			if (jQuery(this).is(':checked')) {  
				jQuery("#mapGoo").show(100);
				jQuery("#mapImg").hide(100);
			}else if (jQuery(this).not(":checked")) {   
				jQuery("#mapGoo").hide(100);
				jQuery("#mapImg").show(100);
			}
		}); 
		jQuery("input[name='notActiveDeal']").click(function(){			
           	if (jQuery(this).is(':checked')) {              
           		var ok = confirm("Deal sẽ ở trạng thái chờ kích hoạt và không hiển thị ở trang chủ ?");  
           		if(ok){               		  
               		jQuery(".time").hide(100);
               		jQuery("#startTime").val("");
               		jQuery("#endTime").val("");
               		jQuery("#expireTime").val("");
           		}else{
           			return false;
           		}        		    
			}               
			else if (jQuery(this).not(":checked")) {                            
				var ok = confirm("Bạn cần điền đầy đủ thông tin ngày tháng để kích hoạt Deal. Lưu ý ngày bắt đầu Deal phải trước ngày hiện tại.");                        
                if(ok){
                	<%
                		Calendar start = Calendar.getInstance();
                		Calendar end = Calendar.getInstance();
                		Calendar expire = Calendar.getInstance();
                		start.setTime(deal.getStartTime());
                		end.setTime(deal.getEndTime());
                		expire.setTime(deal.getExpireTime());
                	%>
					var now = new Date();
                 	jQuery("#startTime").datepicker('setDate', new Date(<%=start.get(Calendar.YEAR)%>, <%=start.get(Calendar.MONTH)%>, <%=start.get(Calendar.DATE)%>));
                 	jQuery("#endTime").datepicker('setDate', new Date(<%=end.get(Calendar.YEAR)%>, <%=end.get(Calendar.MONTH)%>, <%=end.get(Calendar.DATE)%>));
                 	jQuery("#expireTime").datepicker('setDate', new Date(<%=expire.get(Calendar.YEAR)%>, <%=expire.get(Calendar.MONTH)%>, <%=expire.get(Calendar.DATE)%>));
                 	jQuery(".time").show(100);                            
                }else{
                	return false;
                }                   	
			}                    
		}); 
		jQuery("#btnSubmit").click(function(){		
			onSubmitForm("<%=action%>");
			return false;
		}); 
    });
    
    function onSubmitForm(action){         	
    	jQuery.get("/admin/upload/get-url?returnUrl=" + "/admin/deal/" + action, function(data){    	
    		jQuery("#add_deal").attr("action", data);      		
    		jQuery("#add_deal").submit();    		
    	});        	
    }
    
//-->
</script>
		
		<div class="maincontent noright">
        	<div class="maincontentinner">
                <ul class="maintabmenu multipletabmenu">
                	<li><a href="/admin/deal/manage">Thống kê Deal</a></li>      
					<li><a href="/admin/deal/list">Quản lý Deal</a></li>   					             
                	<li class="current">
                		<a href="#">
                			<%
                				if(action!=null&&action.equals("add")){
                					%>
                					Tạo mới Deal	
                					<%
                				}else if(action!=null&&action.equals("edit")){
                					%>
                					Sửa thông tin Deal
                					<%
                				}
                			%>                			
               			</a>
                	</li>
                	<li><a href="/admin/ads/right">Quản lý Deal Quảng cáo</a></li>
                </ul><!--main tab menu-->
                
                <div class="content">
					<jsp:include page="/admin/elements/message.jsp"/>
                    <!--content title-->                
                    <form method="post" enctype="multipart/form-data"  action=""  class="stdform stdform2" id="add_deal">
                    <input type="hidden" name="id" id="id" value="<%=deal.getDealId()%>">                    
	                    <div class="contenttitle">
	                    	<h2 class="form"><span>Thông tin nhân viên kinh doanh</span></h2>
	                    </div>
						<p>
                        	<label>Nhân viên kinh doanh (<span style="color: red">*</span>)</label>
                            <span class="field">
                            	<select id="username" name="username" class="smallinput">
	                            	<%
	                            		for(StaffModel staff: staffData.getActiveListByRole(1)){
	                            	%>
										<option value="<%=staff.getUsername() %>" <%=(deal.getUsername().equalsIgnoreCase(staff.getUsername()))?"selected":""%> ><%=staff.getName() %></option>								
									<%
	                            		}
									%>
								</select>   
								<a href="/admin/staff/add" title="Thêm tài khoản nhân viên">
									&nbsp;(Thêm tài khoản sale)
								</a>                         	
                            	<% if (check.get("username") != null) { %>
									<label for="username" generated="true" class="error"><%=check.get("username") %></label>
								<% } %>
                            </span>                          
						</p>   
						                  
                        <p>
                        	<label>Mã mục lục hợp đồng (<span style="color: red">*</span>)</label>
                        	<span class="field">
                            	<input type="text" class="smallinput" name="contractCode" id="contractCode" value="<%=((deal.getContractCode()!=null) && (deal.getContractCode().length()>0))?deal.getContractCode():""%>">
                            	<% if (check.get("contractCode") != null) { %>
									<label for="contractCode" generated="true" class="error"><%=check.get("contractCode") %></label>
								<% } %>
                            </span>                          
						</p>    									
						<div class="contenttitle">
	                    	<h2 class="form"><span>Thông tin Deal</span></h2>
	                    </div>   
	                    <%
		                    if(action!=null&&action.equals("edit")){
	        					%>
	        			<p>                        	                       
                            <span class="field">
                            	<input type="checkbox" class="smallinput" name="beTopDeal"/> Check để đưa Deal lên top.
                            </span>
						</p>  
	        					<%
	        				}
	                    %>
                      	<p>
                        	<label>Tên Deal (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<input  type="text" class="mediuminput" name="name" id="name" value="<%=((deal.getName()!=null) && (deal.getName().length()>0))?deal.getName():""%>">
                            	<% if (check.get("name") != null) { %>
									<label for="name" generated="true" class="error"><%=check.get("name") %></label>
								<% } %>
                            </span>
						</p>     
						<p>
                        	<label>Tên ngắn (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<input type="text" class="mediuminput" name="shortName" id="shortName" value="<%=((deal.getShortName()!=null) && (deal.getShortName().length()>0))?deal.getShortName():""%>">
                            	<% if (check.get("shortName") != null) { %>
									<label for="shortName" generated="true" class="error"><%=check.get("shortName") %></label>
								<% } %>
                            </span>
						</p>    
						<p>
                        	<label>Viết tắt (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<input type="text" class="mediuminput" name="abbreviation" id="abbreviation" value="<%=((deal.getAbbreviation()!=null) && (deal.getAbbreviation().length()>0))?deal.getAbbreviation():""%>">
                            	<% if (check.get("abbreviation") != null) { %>
									<label for="abbreviation" generated="true" class="error"><%=check.get("abbreviation") %></label>
								<% } %>
                            </span>
						</p>  
						<p>
                        	<label>Thành phố (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<select id="city" name="city" class="smallinput">
	                            	<%
	                            		for(GeoModel city: geoData.getCities()){
	                            	%>
										<option value="<%=city.getGeoId() %>" <%=(deal.getCity().equalsIgnoreCase(city.getGeoId()))?"selected":""%> ><%=city.getName() %></option>								
									<%
	                            		}
									%>
								</select>
								<a href="/admin/geo/add" title="Thêm tỉnh thành mới">
									&nbsp;(Thêm tỉnh thành)
								</a>     
								 <% if (check.get("city") != null) { %>
									<label for="city" generated="true" class="error"><%=check.get("city") %></label>
								<% } %>
                            </span>                           
						</p>
											
						<p>
                        	<label>Danh mục (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<select id="category" name="category" class="smallinput">
									<%
	                            		for(CategoryModel cate: cateData.list()){
	                            	%>
										<option value="<%=cate.getCategoryId() %>" <%=(deal.getCategory().equalsIgnoreCase(cate.getCategoryId()))?"selected":""%>><%=cate.getName() %></option>								
									<%
	                            		}
									%>																
								</select>
								<a href="/admin/category/add" title="Thêm danh mục mới">
									&nbsp;(Thêm danh mục mới)
								</a>     
								<% if (check.get("category") != null) { %>
									<label for="category" generated="true" class="error"><%=check.get("category") %></label>
								<% } %>
                            </span>                           
						</p>										
						<p>
                        	<label>Loại hình sản phẩm (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<select id="productType" name="productType" class="smallinput">
									<option value="0" <%=(deal.getProductType()==0)?"selected":""%>>Phiếu giấy</option>
									<option value="1" <%=(deal.getProductType()==1)?"selected":""%>>Sản phẩm</option>																				
								</select>
								<% if (check.get("productType") != null) { %>
									<label for="productType" generated="true" class="error"><%=check.get("productType") %></label>
								<% } %>
                            </span>                          
						</p>						
						<p>
							<label>Không kích hoạt Deal</label>
							 <span class="field">							 
                            	<input type="checkbox" class="smallinput" name="notActiveDeal" <%=(deal.getStatus()==0)?"checked":""%> />                            	
                            </span>   
						</p>
						<br>
						<%
							SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");	
							Calendar cal = Calendar.getInstance();
							cal.setTime(deal.getStartTime());
						%>
						<p class="time">
                        	<label>Thời gian bắt đầu (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<input type="text" class="smallinput" name="startTime" id="startTime" value="<%=((deal.getStartTime()!=null))?formatter.format(deal.getStartTime()):""%>" style="width: 66px">
                            	<% if (check.get("startTime") != null) { %>
									<label for="startTime" generated="true" class="error"><%=check.get("startTime") %></label>
								<% } %>
								&nbsp;
								<select name="startHour" style="min-width: 8%">
	                            	<%
	                            		for(int i=0;i<24;i++){
	                            	%>
	                            		<option value="<%=i%>" <%=(i==cal.get(Calendar.HOUR_OF_DAY))?"selected":"" %>><%=(i<10)?"0":""%><%=i %></option>
	                            	<%
	                            		}
	                            	%>
	                            </select>&nbsp;&nbsp;:&nbsp; 
	                            <select name="startMinutes" style="min-width: 8%">
	                            	<%
	                            		for(int i=0;i<60;i++){
	                            	%>
	                            		<option value="<%=i%>" <%=(i==cal.get(Calendar.MINUTE))?"selected":""%>><%=(i<10)?"0":""%><%=i %></option>
	                            	<%
	                            		}
	                            	%>
	                            </select>
                            </span>                               
						</p>      
						<%
							cal.setTime(deal.getEndTime());
						%>
						<p class="time">
                        	<label>Thời gian kết thúc (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<input type="text" class="smallinput" name="endTime" id="endTime" value="<%=((deal.getEndTime()!=null))?formatter.format(deal.getEndTime()):""%>" style="width: 66px">
                            	<% if (check.get("endTime") != null) { %>
									<label for="endTime" generated="true" class="error"><%=check.get("endTime") %></label>
								<% } %>
								&nbsp;
								<select name="endHour" style="min-width: 8%">
	                            	<%
	                            		for(int i=0;i<24;i++){
	                            	%>
	                            		<option value="<%=i%>" <%=(i==cal.get(Calendar.HOUR_OF_DAY))?"selected":"" %>><%=(i<10)?"0":""%><%=i %></option>
	                            	<%
	                            		}
	                            	%>
	                            </select>&nbsp;&nbsp;:&nbsp; 
	                            <select name="endMinutes" style="min-width: 8%">
	                            	<%
	                            		for(int i=0;i<60;i++){
	                            	%>
	                            		<option value="<%=i%>" <%=(i==cal.get(Calendar.MINUTE))?"selected":"" %>><%=(i<10)?"0":""%><%=i %></option>
	                            	<%
	                            		}
	                            	%>
	                            </select>
                            </span>                             
						</p>   
						<%
							cal.setTime(deal.getExpireTime());
						%>
						<p class="time">
                        	<label>Hạn sử dụng (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<input type="text" class="smallinput" name="expireTime" id="expireTime" value="<%=((deal.getExpireTime()!=null))?formatter.format(deal.getExpireTime()):""%>" style="width: 66px">
                            	<% if (check.get("expireTime") != null) { %>
									<label for="expireTime" generated="true" class="error"><%=check.get("expireTime") %></label>
								<% } %>
								&nbsp;
								<select name="expireHour" style="min-width: 8%">
	                            	<%
	                            		for(int i=0;i<24;i++){
	                            	%>
	                            		<option value="<%=i%>" <%=(i==cal.get(Calendar.HOUR_OF_DAY))?"selected":"" %>><%=(i<10)?"0":""%><%=i %></option>
	                            	<%
	                            		}
	                            	%>
	                            </select>&nbsp;&nbsp;:&nbsp; 
	                            <select name="expireMinutes" style="min-width: 8%">
	                            	<%
	                            		for(int i=0;i<60;i++){
	                            	%>
	                            		<option value="<%=i%>" <%=(i==cal.get(Calendar.MINUTE))?"selected":"" %>><%=(i<10)?"0":""%><%=i %></option>
	                            	<%
	                            		}
	                            	%>
	                            </select>
                            </span>                           	
						</p>   						   											
						<p>
                        	<label>Loại Deal (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<select id="dealType" name="dealType" class="smallinput">
									<option value="0" <%=(deal.getDealType()==0)?"selected":""%>>Deal thường</option>
									<option value="1" <%=(deal.getDealType()==1)?"selected":""%>>Deal Marketing</option>																				
								</select>
								<% if (check.get("dealType") != null) { %>
									<label for="dealType" generated="true" class="error"><%=check.get("dealType") %></label>
								<% } %>
                            </span>                           
						</p>						
						<p>
                        	<label>Tối đa cho một người mua (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<input type="text" class="smallinput" name="userMaximum" id="userMaximum" value="<%=deal.getUserMaximum()%>" >
                            	<% if (check.get("userMaximum") != null) { %>
									<label for="userMaximum" generated="true" class="error"><%=check.get("userMaximum") %></label>
								<% } %>
                            </span>                           
						</p> 
						<p>
                        	<label>Ngưỡng tối đa (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<input type="text" class="smallinput" name="limit" id="limit" value="<%=deal.getLimit()%>"> (Mặc định kết thúc deal nếu nhỏ hơn hoặc bằng số lượng sản phẩm được mua)
                            	<% if (check.get("limit") != null) { %>
									<label for="limit" generated="true" class="error"><%=check.get("limit") %></label>
								<% } %>
                            </span>                           
						</p> 	
						<p>
                        	<label>Số sản phẩm được mua</label>                        
                        	<span class="field">
                            	<%=deal.getAmount() %>
                            </span>                
						</p> 					
						<p>
                        	<label>Số người mua</label>                        
                        	<span class="field">
                            	<%=deal.getUserAmount() %>
                            </span>                
						</p>   												  							
						<p>
                        	<label>Hình thức giao (<span style="color: red">*</span>)</label>                        
                             <span class="field">
                            	<select id="shipType" name="shipType" class="smallinput">
									<option value="0" <%=(deal.getShipType()==0)?"selected":""%>>Giao tận nơi</option>
									<option value="1" <%=(deal.getShipType()==1)?"selected":""%>>Giao tại công ty</option>		
									<option value="2" <%=(deal.getShipType()==2)?"selected":""%>>Cả hai</option>																				
								</select>
								<% if (check.get("shipType") != null) { %>
									<label for="shipType" generated="true" class="error"><%=check.get("shipType") %></label>
								<% } %>
                            </span>                           
						</p>						
						<div class="contenttitle">
	                    	<h2 class="form"><span>Tạo Voucher cho Deal</span></h2>
	                    </div>  
	                    <%
                    		int count = 0;
                    		List<ProductModel> listProduct = new ArrayList<ProductModel>(); 
							if(deal.getDealId()!=null&&deal.getDealId().length()>0){ 
								listProduct = ProductData.getByDealId(deal.getDealId());
							}	  	                    		
                    	%>   
	                    <p>
	                    	<label>Deal voucher</label>
	                    	<span class="field">
	                    		<input type="checkbox" name="productCheck" id="productCheck" <%=(deal.isHasVoucher())?"checked":"" %> <%=(deal.isHasVoucher()&&listProduct!=null&&listProduct.size()>0)?" disabled":"" %>> Check để tạo voucher cho deal	
	                    	</span>	                    	 	                    
	                    </p>
	                    <p id="productInfor">
	                    	
	                    	<label>Điền thông tin tên voucher</label>
	                    	<span class="field">
	                    	<%
	                    		if(listProduct!=null&&listProduct.size()>0){	  	                    			
	                    			for(int k=0; k<listProduct.size(); k++){
	                    				count++;
	                    	%>
	                    		<input type="text" name="product<%=k+1 %>" value="<%=listProduct.get(k).getName()%>">&nbsp;(Product ID - <%=listProduct.get(k).getProductId()%>)
	                    		<input type="hidden" name="idProduct<%=k+1 %>" value="<%=listProduct.get(k).getProductId()%>">	
	                    		<br><br>
	                    	<%
	                    			}
	                    		}
	                    	%>
	                    	<%
	                    		for(int k=count; k<5; k++){
	                    	%>
	                    		<input type="text" name="product<%=k+1 %>" value=""> 
	                    		<br><br>
	                    	<%
	                    		}
	                    	%>
								<% if (check.get("product") != null) { %>
									<label for="product" generated="true" class="error"><%=check.get("product") %></label>
								<% } %>
	                    	</span>	                    	 	                    
	                    </p>						
						<div class="contenttitle">
	                    	<h2 class="form"><span>Thông tin Giá</span></h2>
	                    </div>   
	                    <p>
                        	<label>Giá nhập (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<input type="text" class="smallinput" name="priceImport" id="priceImport" value="<%=deal.getPriceImport()%>">
								<% if (check.get("priceImport") != null) { %>
									<label for="priceImport" generated="true" class="error"><%=check.get("priceImport") %></label>
								<% } %>
                            </span>                           
						</p>
                      	<p>
                        	<label>Giá bán chưa khuyến mại (<span style="color: red">*</span>)</label>     
                        	                  
                            <span class="field">
                            	<input type="text" class="smallinput" name="price" id="price" value="<%=deal.getPrice()%>">
                            	<% if (check.get("price") != null) { %>
									<label for="price" generated="true" class="error"><%=check.get("price") %></label>
								<% } %>
                            </span>                           	
						</p>
						<p>
                        	<label>Giá bán sau khuyến mại (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<input type="text" class="smallinput" name="priceDiscount" id="priceDiscount" value="<%=deal.getPriceDiscount()%>">
								<% if (check.get("priceDiscount") != null) { %>
									<label for="priceDiscount" generated="true" class="error"><%=check.get("priceDiscount") %></label>
								<% } %>
                            </span>                           
						</p>  
						<p>
                        	<label>Chú thích giá</label>                        
                            <span class="field">
                            	<input type="text" class="mediuminput" name="notePrice" id="notePrice" value="<%=deal.getNotePrice()%>">
                            </span>                           
						</p>  																  						
						<div class="contenttitle">
	                    	<h2 class="form"><span>Cấu hình riêng Deal</span></h2>
	                    </div>   
                      	<p>
                        	<label>Tiêu đề trên trình duyệt (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<input type="text" class="mediuminput" name="webTitle" id="webTitle" value="<%=((deal.getWebTitle()!=null) && (deal.getWebTitle().length()>0))?deal.getWebTitle():""%>">
                            	<% if (check.get("webTitle") != null) { %>
									<label for="webTitle" generated="true" class="error"><%=check.get("webTitle") %></label>
								<% } %>
                            </span>                           	
						</p>     
						<p>                        	                  
                            <span class="field">                            	
                            	<input type="checkbox" name="displayTime" id="displayTime" <%=deal.isDisplayTime()?"checked":""%>> Hiển thị thời gian
                            </span>                            
						</p>     						
						<div class="contenttitle">
	                    	<h2 class="form"><span>Hình ảnh cho Deal</span></h2>
	                    </div>  
	                    <p>
                        	<label>Hình đại diện</label>                                                   
                             <span class="field">
                            	<input type="file" name="dealImages" class="smallinput">&nbsp;&nbsp;(280x190 pixels cho Deal thường) (630x348 pixels cho Deal marketing)
                            </span>                                                                                 
						</p>     
                      	<p>
                        	<label>Hình SlideShow</label>                        
                            <span class="field">
                            	<input type="file" name="dealSlides" class="smallinput">
                            	<input type="file" name="dealSlides" class="smallinput">
                            </span>
                             <span class="field">
                            	<input type="file" name="dealSlides" class="smallinput">
                            	<input type="file" name="dealSlides" class="smallinput">
                            </span>
                             <span class="field">
                            	<input type="file" name="dealSlides" class="smallinput">&nbsp;&nbsp;(440x285 pixels)
                            </span>                                                                                 
						</p>     															
						<div class="contenttitle">
	                    	<h2 class="form"><span>Chi tiết Deal</span></h2>
	                    </div>   
                      	<p>
                        	<label>Thông tin nổi bật (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<textarea id="description" class="longinput ckeditor" name="description"  rows="5" cols="80"><%=((deal.getDescription()!=null) && (deal.getDescription().length()>0))?deal.getDescription():""%></textarea>
                            	<ckeditor:replace replace="description" basePath="/sources/ckeditor/" 
									config="<%=CkeditorConfigHelper.createConfig() %>"
								   events="<%=CkeditorConfigHelper.createEventHandlers() %>" />
                            	<% if (check.get("description") != null) { %>
									<label for="description" generated="true" class="error"><%=check.get("description") %></label>
								<% } %>
                            </span>                           	
						</p>  
						
						<p>
                        	<label>Điều kiện (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<textarea id="dealCondition" class="longinput ckeditor" name="dealCondition"  rows="5" cols="80"><%=((deal.getDealCondition()!=null) && (deal.getDealCondition().length()>0))?deal.getDealCondition():""%></textarea>
                            	<ckeditor:replace replace="dealCondition" basePath="/sources/ckeditor/" 
									config="<%=CkeditorConfigHelper.createConfig() %>"
								   events="<%=CkeditorConfigHelper.createEventHandlers() %>" />
								<% if (check.get("dealCondition") != null) { %>
									<label for="dealCondition" generated="true" class="error"><%=check.get("dealCondition") %></label>
								<% } %>
                            </span>                           
						</p> 
												
                      	<p>
                        	<label>Giới thiệu chi tiết (<span style="color: red">*</span>)</label>                        
                            <span class="field">
                            	<textarea id="content" class="longinput ckeditor" name="content"  rows="5" cols="80"><%=((deal.getContent()!=null) && (deal.getContent().length()>0))?deal.getContent():""%></textarea>
                            	<ckeditor:replace replace="content" basePath="/sources/ckeditor/" 
									config="<%=CkeditorConfigHelper.createConfig() %>"
								   events="<%=CkeditorConfigHelper.createEventHandlers() %>" />
                            	<% if (check.get("content") != null) { %>
									<label for="content" generated="true" class="error"><%=check.get("content") %></label>
								<% } %>
                            </span>                           	
						</p>     
						<p>
                        	<label>
                        		Địa chỉ cung cấp (<span style="color: red">*</span>)                        		
                        	</label>                        
                             <span class="field">                            	
                            	<textarea class="longinput ckeditor" name="addressInformation" id="addressInformation"><%=((deal.getAddressInformation()!=null) && (deal.getAddressInformation().length()>0))?deal.getAddressInformation():""%></textarea>
                            	<ckeditor:replace replace="addressInformation" basePath="/sources/ckeditor/" 
									config="<%=CkeditorConfigHelper.createConfig() %>"
								   events="<%=CkeditorConfigHelper.createEventHandlers() %>" />
                            	<br>   
                            	<% if (check.get("addressInformation") != null) { %>
									<label for="addressInformation" generated="true" class="error"><%=check.get("addressInformation") %></label>
								<% } %>                                              	
                            	<input type="checkbox" id="mapGoogle" name="mapGoogle" <%=deal.isDisplayMap()?"checked":"" %> > Hiển thị thông tin bản đồ bằng Google Map
                            	       	                           
                            </span>
						</p>  
						<p id="mapGoo">
                        	<label>
                        		Thông tin bản đồ                        		
                        	</label>                        
                             <span class="field">                            	
                            	<input type="text" class="mediuminput" name="mapInformation" id="mapInformation" value="<%=((deal.getMapInformation()!=null) && (deal.getMapInformation().length()>0))?deal.getMapInformation():""%>">
                            	<br>
                            	<small>(Vị trí bản đồ sẽ được xác định dựa vào thông tin này. Vui lòng nhập chính xác địa chỉ Deal.)</small>                            	
                            </span>
						</p>  
						
						<p id="mapImg">
                        	<label>Hình ảnh bản đồ</label>                                                   
                             <span class="field">
                            	<input type="file" name="mapImg" class="smallinput">&nbsp;&nbsp;(460x300 pixels)
                            </span>                                                                                 
						</p>  												                   		 												                                   
                        <p>
                        	<label></label>
                        	<span class="field">        
                        		<button class="submit radius2" id="btnSubmit">Lưu Deal</button>
                            	<input type="reset" value="Reset" class="reset radius2">
                            </span>
                        </p>                        
                    </form>                                                           
                    <br clear="all">                    
                </div>
                <!--content-->                
            </div>
            <!--main content inner-->            
            <jsp:include page="/admin/elements/copyright.jsp">
            	<jsp:param name="language" value="1" />
			</jsp:include>            
        </div>
<jsp:include page="/admin/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>